import React from 'react';
import { Descriptions, Card } from 'antd';

import { getDicByKey } from '@/support/common';
import PropTypes from 'prop-types';
export default class DriveMotorTab extends React.Component<any, any> {
  static contextTypes = {
    dicData: PropTypes.any,
  };

  componentWillUnmount = () => {
    this.setState = (state, callback) => {
      return;
    };
  };
  render() {
    const { context } = this;
    const { driveMotorTotal, driveMotorVoList } = this.props;

    const driveMotorVo = driveMotorVoList
      ? driveMotorVoList.map((item, index) => {
          return (
            <Descriptions
              bordered
              size="small"
              style={{ padding: 0, marginTop: 20, fontWeight: 'normal' }}
              title={item.motorSeq ? `${item.motorSeq}驱动电机信息` : ''}
              key={item.motorSeq}
            >
              <Descriptions.Item label="驱动电机序号">{item.motorSeq}</Descriptions.Item>
              <Descriptions.Item label="驱动电机状态">
                {getDicByKey(context.dicData, 'motorStatus', item.motorStatus)}
              </Descriptions.Item>
              <Descriptions.Item label="驱动电机控制器温度(℃)">
                {item.motorControlTemperature ? `${item.motorControlTemperature}` : ''}
              </Descriptions.Item>
              <Descriptions.Item label="驱动电机转速(r/min)">
                {item.motorSpeed ? `${item.motorSpeed}` : ''}
              </Descriptions.Item>
              <Descriptions.Item label="驱动电机转矩(N*m)">
                {item.motorTorque ? `${item.motorTorque}` : ''}
              </Descriptions.Item>
              <Descriptions.Item label="驱动电机温度(℃)">
                {item.motorTemperature ? `${item.motorTemperature}` : ''}
              </Descriptions.Item>
              <Descriptions.Item label="电机控制器输入电压(V)">
                {item.motorControlVoltage ? `${item.motorControlVoltage}` : ''}
              </Descriptions.Item>
              <Descriptions.Item label="电机控制器直流母线电流(A)">
                {item.motorBusCurrent ? `${item.motorBusCurrent}` : ''}
              </Descriptions.Item>
              <Descriptions.Item label=""></Descriptions.Item>
            </Descriptions>
          );
        })
      : '';
    return (
      <>
        <Descriptions bordered size="small">
          <Descriptions.Item label="驱动电机个数">{driveMotorTotal}</Descriptions.Item>
        </Descriptions>

        {driveMotorVo}
      </>
    );
  }
}
